package org.andengine.shmup;

import java.util.LinkedList;
import java.util.List;

import org.andengine.bulletml.simple.BossData;
import org.simpleframework.xml.*;

/*
 * Currently the Level is meant to serve as an XML Container
 * and uses a stack to pop out enemies
 */

@Root
public class Level {
	
	@Attribute (required = false)
	public String name;
	
	@ElementList (name = "waves", type = EnemyWave.class, required = false)
	private List<EnemyWave> waveList;
	
	@Element (required = true)
	private BossData boss; 

	public Level(){
		waveList = new LinkedList<EnemyWave>();
	}

	public LinkedList<EnemyWave> getWaveList() {
		return (LinkedList<EnemyWave>) waveList;
	}
	
	public EnemyWave getNextWave(){
		if(this.hasNextWave())
			return ((LinkedList<EnemyWave>) waveList).poll();
		else
			return null;
	}
	
	public boolean hasNextWave(){
		return !waveList.isEmpty();
	}
	
	public String toString(){
		String out = "";
		if(!this.hasNextWave())
			return "empty level";
		for(int x = 0; x < waveList.size();x++){
			out = out + "Wave " + x + ":\n" + waveList.get(x).toString() + "\n";
		}
		return out + "\n";
	}
	/* To be dummied out at the end. */
	public void addWave(EnemyWave ew){
		waveList.add(ew);
	}

	public String getName() {
		return name;
	}

	public final BossData getBoss() {
		return boss;
	}
}
